using System;
using System.Collections;

namespace Tasks
{
	public class EnumerableTask : IEnumerable
	{
		public EnumerableTask(ITask task)
		{
			this.task = task;
		}

		public ITask task { get; private set; }

		public IEnumerator GetEnumerator()
		{
			this.task.Execute();
			while (!this.task.isDone)
			{
				yield return null;
			}
			yield break;
		}

		public override string ToString()
		{
			return this.task.ToString();
		}
	}
}
